#ifndef VIDEODECODETASK_H
#define VIDEODECODETASK_H
#include "Task_Base/Task_Base.h"
#include "Receive_handler.h"
#include "Task_Base/CriticalSection.h"
struct AVStream;
class SwsContext;
class AVFrame;
class SynImagehandler;
class VideoDecodeTask : public Task_Base, public Receive_handler
{
public:
    VideoDecodeTask();
    ~VideoDecodeTask();
public:
    bool Init(AVStream*,SynImagehandler*);
    void UnInit();
    virtual int close();
    virtual bool receive_handler(const char *data,int size);
protected:
    virtual int svc();//主动工作线程函数 (视频解码工作)
private:
    void checkout_swsconvert();
    bool no_data_decode(AVFrame * pFrame,unsigned char *pBuffer);
    bool has_data_decode(const char *data, int len,AVFrame * pFrame,unsigned char *pBuffer);
private:
    double      synchronize_video(AVFrame *src_frame, double pts);
private:
    AVStream        *m_pVStream;

    double          video_clock;

    SwsContext      *img_convert_ctx;

    AVFrame         *pFrameRGB24;

    unsigned char   *bufferRGB ;

    SynImagehandler *syn_image_handler;

    bool            bExit;

    int             skipped_frame ;
};

#endif // VIDEODECODETASK_H
